package com.wsc.controller;


import java.io.FileWriter;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

public class Logger {
	//writes the given message to the given log file
	public static void writeLog(String file, String msg)throws IOException{
			Date date = new Date();
			String time = date.toString();
			FileWriter write_log = new FileWriter(file,true);
			write_log.flush();
			write_log.write(time+"  "+msg+" \n");
	}
	
	//generates the log file name and returns
	public static String logfile(String filename){
		Date dt = new Date();
		DateFormat df = new SimpleDateFormat("yyyy-mm-dd"); //generates the current date
		filename = filename+df.format(dt); //log file name
		return filename;
	}
	
}
